<?php
/**
 * Tongji 插件
 * @author 后盾向军 <houdunwangxj@gmail.com>
 */
class TongjiAddon extends Addon
{

    //插件信息
    public $info = array(
        'name' => 'Tongji',
        'title' => '访问统计',
        'description' => '统计访问信息',
        'status' => 1,
        'author' => 'long',
        'version' => '1.0',
        'has_adminlist' => 1,
    );

    //安装
    public function install()
    {
        if (!M()->exe("DROP TABLE IF EXISTS `" . C('DB_PREFIX') . "tongji`")) return false;
        if (!M()->exe("CREATE TABLE `" . C('DB_PREFIX') . "tongji` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `ip` varchar(100) DEFAULT NULL COMMENT 'ip',
  `click` int(10) unsigned DEFAULT NULL COMMENT '访问次数',
  `sheng` varchar(100) DEFAULT NULL COMMENT '省份',
  `city` varchar(100) DEFAULT NULL COMMENT '城市',
  `browser` varchar(100) DEFAULT NULL COMMENT '浏览器',
  `domain` varchar(100) DEFAULT NULL COMMENT '访问域名',
  `referer` varchar(100) DEFAULT NULL COMMENT '来源',
  `time` int(11) DEFAULT NULL,
  `status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 1 未屏蔽 0 屏蔽',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='ip统计表'")
        ) return false;
        return true;
    }

    //卸载
    public function uninstall()
    {
        if (!M()->exe("DROP TABLE IF EXISTS `" . C('DB_PREFIX') . "tongji`")) return false;
        return true;
    }}